import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user:{
      username:'',
      password:'',
      email:'',
      birthday:'',
      role:'',
      salary:'',
      avatar:'',
    },
    userList:{
      id:'',

    },
    theme: 'blue'
  },
  getters: {
    username: state => state.user.username,
    password: state => state.user.password,
    email: state => state.user.email,
    birthday: state => state.user.birthday,
    role: state => state.user.role,
    avatar: state => state.user.avatar,
    theme: state => state.theme
  },
  mutations: {
    SET_USERNAME(state,username){
      state.user.username = username;
    },
    SET_PASSWORD(state,password){
      state.user.password = password;
    },
    SET_EMAIL(state,email){
      state.user.email = email;
    },
    SET_BIRTHDAY(state,birthday){
      state.user.birthday = birthday;
    },
    SET_ROLE(state,role){
      state.user.role = role;
    },
    SET_SALARY(state,salary){
      state.user.salary = salary;
    },
    SET_AVATAR(state,avatar){
      state.user.avatar = avatar;
    },
    SET_THEME(state,theme){
      state.theme = theme;
    }
  },
  actions: {
    setUsername({commit},username){
      commit('SET_USERNAME',username);
    },
    setPassword({commit},password){
      commit('SET_PASSWORD',password);
    },
    setEmail({commit},email){
      commit('SET_EMAIL',email);
    },
    setBirthday({commit},birthday){
      commit('SET_BIRTHDAY',birthday);
    },
    setRole({commit},role){
      commit('SET_ROLE',role);
    },
    setSalary({commit},salary){
      commit('SET_SALARY',salary);
    },
    setAvatar({commit},avatar){
      commit('SET_AVATAR',avatar);
    },
    setTheme({commit},theme){
      commit('SET_THEME',theme);
    }
  },
  modules: {
  }
})
